package com.igeek.user.dao;

import com.igeek.user.entity.Girl;

import java.util.List;

public class GirlDaoImpl extends BaseDao<Girl> implements IDao<Girl>{

    @Override
    public Girl selectOne(Girl girl) {
        Girl bean = this.getBean(Girl.class, "select * from girl where id = ?", girl.getId());
        return bean;
    }

    @Override
    public int insert(Girl girl) {
        int count = this.update("insert into girl values(null,?,?,?,?,null,?)",
                girl.getName(), girl.getSex(), girl.getBorndate(),
                girl.getPhone(), girl.getBoyFriendId());
        System.out.println(count>0 ? "插入成功" : "插入失败");
        return count;
    }

    @Override
    public List<Girl> selectAll(String query) {
        List<Girl> beanList = this.getBeanList(Girl.class,
                "select * from girl where name like concat('%', ? ,'%')", query);
        return beanList;
    }
}
